<include file="__THEME__/header" />
<script type="text/javascript" src="__PUBLIC__/js/jquery.form.js" ></script>
<link href="../Public/css/space.css" rel="stylesheet" type="text/css" />
<link href="../Public/css/colleague.css" rel="stylesheet" type="text/css" />

<script>
//添加用户组
function doaddgroup(){
	var groupname = $.trim($('#groupname').val());
	if(groupname){
		$.post('{:U("home/Colleague/managegroup")}',{groupname:groupname,type:'add'},function(txt){
			txt = eval('('+txt+')');
			if(txt.status){
				html = '<dd id="group_'+txt.info+'"><a class="del" href="javascript:void(0)" onclick="dodelgroup('+txt.info+')" title="'+'{:L("delete")}'+'"></a><a href="{:U("home/Colleague/index")}&g='+txt.info+'">'+groupname+'</a></dd>';
				$('#group_add').before(html);
				$('#groupname').val('');
			}else{
				$.tbox.no(txt.info,"{:L('fail_add')}");
			}
		});
	}else{
		$.tbox.no("{:L('no_empty_group')}","{:L('fail_add')}");
	}
}

//编辑用户组
function doeditgrouphandle(id){
	var html = '<div style="width:350px" class="Flist"><ul style="padding-left:50px" class="mt10 lh25">'
		     + '<li class="LW">{:L("group_name")}: '+$("#grouphandle_"+id).html()+'</li>'
		     + '<li>{:L("group_name_new")}: <input class="in_put" type="text" name="editgroupname" id="editgroupname" ></li>'
		     + '</ul></div>'
		     + '<div style="display: block;" id="tb_content_list" class="tb_button_list">'
			 + '<p style="color:red" id="edit_group_message">&nbsp;</p>'
		     + '<p><input type="button" value="{:L("ok")}" onclick="doeditgroup('+id+')" id="tb_button_ok" class="mr10"/><input type="button" value="{:L("cancel")}" id="tb_button_no" onclick="$.tbox.close()" name="" class="mr10"/>'
		     + '</p></div>';
	$.tbox.popBox(html,"{:L('edit_group')}");
}

function doeditgroup(id){
	var groupname = $('#editgroupname').val();
	$.post('{:U("home/Colleague/managegroup")}',{id:id,type:'edit',groupname:groupname},function(txt){
		txt = eval('('+txt+')');
		if(txt.status){
			$("#grouphandle_"+id).html(groupname);
			$.tbox.close();
		}else{
			$('#edit_group_message').html( txt.info );
		}
	});
}

//删除用户组
function dodelgroup(id){
	$.post('{:U("home/Colleague/managegroup")}',{id:id,type:'del'},function(txt){
		txt = eval('('+txt+')');
		if(txt.status){
			$("#group_"+id).remove();
		}else{
			if( txt.info != 0){
				$.tbox.popup("{:U('home/Colleague/changenew')}&gid="+id,"{:L('transfer_col')}",{ok:'dochangegroupdel()'});
			}else{
				$.tbox.no(txt.info,"{:L('fail')}");
			}
		}
	});
}

//编辑同事
function doedithandle(cid){
	$.tbox.popup("{:U('home/Colleague/editFriend')}&cid="+cid,"{:L('edit_col')}");
}

//执行操作
function doedit(cid){
	var gids = $("input[name='selectGids[]']").fieldValue();

	var remark = $('#doeditremark').val();
	$.post('{:U("home/Colleague/managecolleague")}',{type:'edit',cid:cid,gids:gids,remark:remark},function(txt){

		txt = eval('('+txt+')');
		if(txt.status){
			$("#list_group_"+cid).html(txt.info);
			$("#list_remark_"+cid).html(remark);
			$.tbox.close();
		}else{
			$.tbox.no(txt.info,"{:L('fail')}");
		}
	});
}

//删除
function dodel(id){
	if(confirm("{:L('sure_delete_col')}")){
		$.post('{:U("home/Colleague/managecolleague")}',{cid:id,type:'del'},function(txt){
			txt = eval('('+txt+')');
			if(txt.status){
				$("#colleague_"+id).remove();
			}else{
				$.tbox.no(txt.info,"{:L('fail')}");
			}
		});
	}
}
</script>
<div class="contents lbg B"> <include file="../Public/home_left" />
  <div class="contents_min w787">
    <div class="write_info">
      <div class="mb10">
       <h3 class="tit_h3">{:L('my_contact')}</h3>
      </div>
        <div class="list_cate_nav">
      <div class="tab">
        <!-- 切换标签 begin  -->
        <ul>
          <li class="on"><span><a href="__URL__&act=index">{:L('nav_index')}</a></span></li>
          <li><span><a href="__URL__&act=add">{:L('nav_add')}</a></span></li>
          <li><span><a href="__URL__&act=search">{:L('nav_search')}</a></span></li>
          <li><span><a href="__URL__&act=track">{:L('nav_track')}</a></span></li>
          <li><span><a href="__URL__&act=followYou">{:L('nav_followyou')}</a></span></li>
          <li><span><a href="__URL__&act=followMe">{:L('nav_followme')}</a></span></li>				  
        </ul>
      </div>
      <div class="friendBox">
        <div class="sidebar_R">
          <dl class="FSort base_input">
            <dt>{:L('col_group')}</dt>
            <dd <php>if($_GET['g']==''){</php>class="ic"<php>}else{</php>class="i"<php>}</php> ><a href="__URL__">{:L('all')}</a></dd>
            <volist id="vo" name="grouplist">
            <php>$class = ($key==$_GET['g'])?'ic':'i'</php>
            	<dd class="{$class}" id="group_{$key}"><span class="sap_R"><a class="del" href="javascript:void(0)" onclick="dodelgroup({$key})" title="{:L('delete')}"></a><a class="ico_edi R" href="javascript:void(0)" onclick="doeditgrouphandle({$key})" title="{:L('edit')}"></a></span><a href="__URL__&act=index&g={$key}" id="grouphandle_{$key}">{$vo}</a> </dd>
            </volist>
            <dd id="group_add"><a href="javascript:void(0)" onclick="$('#group_add').hide();$('#group_doadd').show();">{:L('add_group')}</a></dd>
            <dd id="group_doadd" style="display:none"> 
              <input name="groupname" id="groupname" type="text" style="width:130px; margin-bottom:2px;" class="in_put"/>
              <input type="button" value="{:L('ok')}" class="btn_r" onclick="doaddgroup()"/>
              <input type="button" value="{:L('cancel')}" class="btn_r" onclick="$('#group_doadd').hide();$('#group_add').show();" />
            </dd>
          </dl>
        </div>
        <div class="FList f12">

            <h2>{:L('contact_list',array('$i'=>$count))}</h2>
          <ul style="padding: 0px;margin: 10px auto 0px 15px;">
          <volist id="vo" name="data">
            <li class="btmlineD li pb10 pt5" id="colleague_{$vo.cid}" >
              <div class="L" style="width:70px;"><span class="headpic50"> <a href="{:U('space/View/index','uid='.$vo['fid'])}" ><img src="{$vo.fid|getUserFace='s'}" /></a></span></a></div>
              <div class="L" style="width: 450px;">
                <p class="lh20"><a href="{:U('space/View/index','uid='.$vo['fid'])}" id="fname_10000">{$vo.fid|getUserName}</a></p>
                <p class="cl06 lh20" >{:L('group')}：<span id="list_group_{$vo.cid}">{$vo.gname|implode=','}</span></p>
                <p class="cl06 lh20" ><span class="wn">{:L('remark')}：</span><span id="list_remark_{$vo.cid}">{$vo.remark}</span></p>
              </div>
              <div class="L" style="width:60px;">
                <p class="lh20"><a href="{:U('space/View/index','uid='.$vo['fid'])}" >{:L('view_space')}</a></p>
                <p class="lh20 alC"><a title="删除" class="del mr10" href="javascript:void(0)" onclick="dodel({$vo.cid})"></a><a title="编辑" class="ico_edi" href="javascript:void(0)" onclick="doedithandle({$vo.cid})"></a> </p>
              </div>
              <div class="C"></div>
            </li>
      	 </volist>
          </ul>
           <div class="page mt5 alR mb20"> {$html} </div>
        </div>
      </div>
      </div>
    </div>
  </div>
  <div class="C"></div>
</div>
<include file="__THEME__/footer" /> 